home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / glibmm-2.4 / glibmm / spawn.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-04-20  |  6.7 KB  |  204 lines

  1. // -*- c++ -*-
  2. // Generated by gtkmmproc -- DO NOT MODIFY!
  3. #ifndef _GLIBMM_SPAWN_H
  4. #define _GLIBMM_SPAWN_H
  5.  
  6.  
  7. /* $Id: spawn.hg,v 1.4 2004/03/02 23:29:57 murrayc Exp $ */
  8.  
  9. /* Copyright (C) 2002 The gtkmm Development Team
  10.  *
  11.  * This library is free software; you can redistribute it and/or
  12.  * modify it under the terms of the GNU Library General Public
  13.  * License as published by the Free Software Foundation; either
  14.  * version 2 of the License, or (at your option) any later version.
  15.  *
  16.  * This library is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  19.  * Library General Public License for more details.
  20.  *
  21.  * You should have received a copy of the GNU Library General Public
  22.  * License along with this library; if not, write to the Free
  23.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  */
  25.  
  26.  
  27. #include <string>
  28. #include <sigc++/sigc++.h>
  29. #include <glibmm/arrayhandle.h>
  30. #include <glibmm/error.h>
  31.  
  32. #include <glibmmconfig.h>
  33. GLIBMM_USING_STD(string)
  34.  
  35.  
  36. namespace Glib
  37. {
  38.  
  39. typedef GPid Pid;
  40.  
  41. /** @addtogroup glibmmEnums Enums and Flags */
  42.  
  43. /**
  44.  * @ingroup glibmmEnums
  45.  * @par Bitwise operators:
  46.  * <tt>%SpawnFlags operator|(SpawnFlags, SpawnFlags)</tt><br>
  47.  * <tt>%SpawnFlags operator&(SpawnFlags, SpawnFlags)</tt><br>
  48.  * <tt>%SpawnFlags operator^(SpawnFlags, SpawnFlags)</tt><br>
  49.  * <tt>%SpawnFlags operator~(SpawnFlags)</tt><br>
  50.  * <tt>%SpawnFlags& operator|=(SpawnFlags&, SpawnFlags)</tt><br>
  51.  * <tt>%SpawnFlags& operator&=(SpawnFlags&, SpawnFlags)</tt><br>
  52.  * <tt>%SpawnFlags& operator^=(SpawnFlags&, SpawnFlags)</tt><br>
  53.  */
  54. enum SpawnFlags
  55. {
  56.   SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0,
  57.   SPAWN_DO_NOT_REAP_CHILD = 1 << 1,
  58.   SPAWN_SEARCH_PATH = 1 << 2,
  59.   SPAWN_STDOUT_TO_DEV_NULL = 1 << 3,
  60.   SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
  61.   SPAWN_CHILD_INHERITS_STDIN = 1 << 5,
  62.   SPAWN_FILE_AND_ARGV_ZERO = 1 << 6
  63. };
  64.  
  65. /** @ingroup glibmmEnums */
  66. inline SpawnFlags operator|(SpawnFlags lhs, SpawnFlags rhs)
  67.   { return static_cast<SpawnFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
  68.  
  69. /** @ingroup glibmmEnums */
  70. inline SpawnFlags operator&(SpawnFlags lhs, SpawnFlags rhs)
  71.   { return static_cast<SpawnFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
  72.  
  73. /** @ingroup glibmmEnums */
  74. inline SpawnFlags operator^(SpawnFlags lhs, SpawnFlags rhs)
  75.   { return static_cast<SpawnFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
  76.  
  77. /** @ingroup glibmmEnums */
  78. inline SpawnFlags operator~(SpawnFlags flags)
  79.   { return static_cast<SpawnFlags>(~static_cast<unsigned>(flags)); }
  80.  
  81. /** @ingroup glibmmEnums */
  82. inline SpawnFlags& operator|=(SpawnFlags& lhs, SpawnFlags rhs)
  83.   { return (lhs = static_cast<SpawnFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
  84.  
  85. /** @ingroup glibmmEnums */
  86. inline SpawnFlags& operator&=(SpawnFlags& lhs, SpawnFlags rhs)
  87.   { return (lhs = static_cast<SpawnFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
  88.  
  89. /** @ingroup glibmmEnums */
  90. inline SpawnFlags& operator^=(SpawnFlags& lhs, SpawnFlags rhs)
  91.   { return (lhs = static_cast<SpawnFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
  92.  
  93.  
  94. /** @defgroup Spawn Spawning Processes
  95.  * Process launching with fork()/exec().
  96.  * @{
  97.  */
  98.  
  99. /** Exception class for errors occuring when spawning processes.
  100.  */
  101. class SpawnError : public Glib::Error
  102. {
  103. public:
  104.   enum Code
  105.   {
  106.     FORK,
  107.     READ,
  108.     CHDIR,
  109.     ACCES,
  110.     PERM,
  111.     TOOBIG,
  112.     NOEXEC,
  113.     NAMETOOLONG,
  114.     NOENT,
  115.     NOMEM,
  116.     NOTDIR,
  117.     LOOP,
  118.     TXTBUSY,
  119.     IO,
  120.     NFILE,
  121.     MFILE,
  122.     INVAL,
  123.     ISDIR,
  124.     LIBBAD
  125.   };
  126.  
  127.   SpawnError(Code error_code, const Glib::ustring& error_message);
  128.   explicit SpawnError(GError* gobject);
  129.   Code code() const;
  130.  
  131. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  132. private:
  133.   static void throw_func(GError* gobject);
  134.   friend void wrap_init(); // uses throw_func()
  135. #endif
  136. };
  137.  
  138.  
  139. void spawn_async_with_pipes(const std::string& working_directory,
  140.                             const Glib::ArrayHandle<std::string>& argv,
  141.                             const Glib::ArrayHandle<std::string>& envp,
  142.                             SpawnFlags flags = SpawnFlags(0),
  143.                             const sigc::slot<void>& child_setup = sigc::slot<void>(),
  144.                             Pid* child_pid = 0,
  145.                             int* standard_input = 0,
  146.                             int* standard_output = 0,
  147.                             int* standard_error = 0);
  148.  
  149. void spawn_async_with_pipes(const std::string& working_directory,
  150.                             const Glib::ArrayHandle<std::string>& argv,
  151.                             SpawnFlags flags = SpawnFlags(0),
  152.                             const sigc::slot<void>& child_setup = sigc::slot<void>(),
  153.                             Pid* child_pid = 0,
  154.                             int* standard_input = 0,
  155.                             int* standard_output = 0,
  156.                             int* standard_error = 0);
  157.  
  158. void spawn_async(const std::string& working_directory,
  159.                  const Glib::ArrayHandle<std::string>& argv,
  160.                  const Glib::ArrayHandle<std::string>& envp,
  161.                  SpawnFlags flags = SpawnFlags(0),
  162.                  const sigc::slot<void>& child_setup = sigc::slot<void>(),
  163.                  Pid* child_pid = 0);
  164.  
  165. void spawn_async(const std::string& working_directory,
  166.                  const Glib::ArrayHandle<std::string>& argv,
  167.                  SpawnFlags flags = SpawnFlags(0),
  168.                  const sigc::slot<void>& child_setup = sigc::slot<void>(),
  169.                  Pid* child_pid = 0);
  170.  
  171. void spawn_sync(const std::string& working_directory,
  172.                 const Glib::ArrayHandle<std::string>& argv,
  173.                 const Glib::ArrayHandle<std::string>& envp,
  174.                 SpawnFlags flags = SpawnFlags(0),
  175.                 const sigc::slot<void>& child_setup = sigc::slot<void>(),
  176.                 std::string* standard_output = 0,
  177.                 std::string* standard_error = 0,
  178.                 int* exit_status = 0);
  179.  
  180. void spawn_sync(const std::string& working_directory,
  181.                 const Glib::ArrayHandle<std::string>& argv,
  182.                 SpawnFlags flags = SpawnFlags(0),
  183.                 const sigc::slot<void>& child_setup = sigc::slot<void>(),
  184.                 std::string* standard_output = 0,
  185.                 std::string* standard_error = 0,
  186.                 int* exit_status = 0);
  187.  
  188. void spawn_command_line_async(const std::string& command_line);
  189.  
  190. void spawn_command_line_sync(const std::string& command_line,
  191.                              std::string* standard_output = 0,
  192.                              std::string* standard_error = 0,
  193.                              int* exit_status = 0);
  194.  
  195. void spawn_close_pid(Pid pid);                             
  196.  
  197. /** @} group Spawn */
  198.  
  199. } // namespace Glib
  200.  
  201.  
  202. #endif /* _GLIBMM_SPAWN_H */
  203.  
  204.